﻿/*
 * My Timer - frmChangeOpacity.cs
 * 
 * Copyright (C) 2009 Ahmad Hanis Azmi
 * 
 * This file is part of My Timer
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace My_Timer
{
    public partial class frmChangeOpacity : Form
    {
        public frmChangeOpacity()
        {
            InitializeComponent();
            this.Deactivate += new EventHandler(this.frmChangeTransparency_Deactivate);
            this.Load += new EventHandler(this.frmChangeTransparency_Load);
        }

        private void frmChangeTransparency_Load(object sender, EventArgs e)
        {
            trackBar1.Value = (int)(this.Owner.Opacity * trackBar1.Maximum);
            numericUpDown1.Value = (int)(this.Owner.Opacity * trackBar1.Maximum);
        }

        private void frmChangeTransparency_Deactivate(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            numericUpDown1.Value = trackBar1.Value;
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            //MessageBox.Show(sender.ToString());
            trackBar1.Value = (int)numericUpDown1.Value;
            set_OwnerTransparency();
        }

        private void set_OwnerTransparency()
        {
            int i = (int)Tag;
            double d_frmTImersPopupOpacity = (double)trackBar1.Value / trackBar1.Maximum;
            this.Owner.Opacity = d_frmTImersPopupOpacity;

            TimersArray t_TimersArray = GlobalClass.r_Timers[i];
            t_TimersArray.form_Opacity = d_frmTImersPopupOpacity;
            GlobalClass.r_Timers[i] = t_TimersArray;
        }
    }
}
